﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title id='title'></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1">
    <meta name="apple-itunes-app" content="app-id=931370041">
    <meta name="google" content="notranslate"/>
    <link id='ico' rel="shortcut icon" type="image/x-icon" href="">
</head>
<style>
    body {
        color: #333;
        margin: 0;
    }

    div {
        margin: 0;
        padding: 0;
    }

    .content {
        padding: 40px 84px;
        background: #fff;
        display: none;
    }

    .contentLoading {
        padding: 40px 84px;
        background: #fff;
        display: none;
        text-align: center;
    }

    .logo {
        display: block;
        width: 105px;
        height: 45px;
        background-size: 105px 45px;
        background-repeat: no-repeat;
        background-position: left center;
    }

    .formCon {
        width: 500px;
        height: 510px;
        background-color: #FFFFFF;
        box-shadow: 0 10px 25px 0 rgba(0, 18, 57, 0.10);
        border-radius: 10px;
        padding-left: 400px;
        background-size: 400px 510px;
        margin: 40px auto 0;
        background-position: left center;
        background-repeat: no-repeat;
        background-image: url(https://app-op-public-prod.oss-cn-beijing.aliyuncs.com/p_fcbanner/p_fc_banner.jpg);
    }

    @media screen and (min-height: 800px) {
    }

    .input {
        width: 300px;
        outline: none;
        border: 0;
        border-bottom: 1px solid #E5E7ED;
        padding-bottom: 8px;
        font-size: 14px;
    }

    ::-webkit-input-placeholder {
        /* WebKit browsers */
        color: #A2A8B4;
    }

    :-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #A2A8B4;
    }

    ::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #A2A8B4;
    }

    :-ms-input-placeholder {
        /* Internet Explorer 10+ */
        color: #A2A8B4;
    }

    .group {
        margin-bottom: 15px;
    }

    .btn {
        background: rgb(24, 144, 255);
        width: 300px;
        height: 40px;
        text-align: center;
        line-height: 40px;
        border-radius: 4px;
        color: #fff;
        border: 0;
        font-size: 16px;
        cursor: pointer;
        outline: none;
    }

    .error {
        height: 25px;
        width: 300px;
        color: #f04134;
        margin: 0 auto;
        font-size: 14px;
    }

    @keyframes shake {
        from,
        to {
            transform: translate3d(0, 0, 0);
        }
        10%,
        30%,
        50%,
        70%,
        90% {
            transform: translate3d(-10px, 0, 0);
        }
        20%,
        40%,
        60%,
        80% {
            transform: translate3d(10px, 0, 0);
        }
    }

    .shake {
        animation-name: shake;
        animation-duration: 1s;
        animation-fill-mode: both;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    .fadeIn {
        animation-name: fadeIn;
        animation-duration: 1s;
    }

    .forget {
        width: 300px;
        margin: 0 auto;
        text-align: right;
        margin-top: 16px;
    }

    .forget-psw {
        text-decoration: none;
        color: #A2A8B4;
        font-size: 14px;
    }

    .title {
        font-size: 12px;
        margin-bottom: 60px;
    }

    .back {
        color: #3389FF;
        text-decoration: none;
        font-size: 12px;
    }

    .send-con {
        position: relative;
        width: 300px;
        height: 31px;
        overflow: hidden;
        margin: 0 auto;
    }

    .send-code {
        color: #3389FF;
        border: 0;
        position: absolute;
        right: 0;
        bottom: 5px;
        font-size: 14px;
        cursor: pointer;
        text-decoration: none;
    }

    #login {
        width: 500px;
        text-align: center;
        padding-top: 64px;
    }

    .formTitle {
        font-size: 22px;
        color: #333333;
        margin-bottom: 90px;
    }

    #forget-fist,
    #forget-second {
        width: 500px;
        text-align: center;
        padding-top: 64px;
    }

    #change-new-password {
        width: 500px;
        text-align: center;
        padding-top: 64px;
    }

    .PassWordtitle {
        font-size: 22px;
        color: #333333;
    }

    .forgetTitle {
        font-size: 22px;
        color: #333333;
    }

    .goNext {
        margin-top: 25px;
        margin-bottom: 10px;
    }

    input:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
        -webkit-text-fill-color: #3E3E3E !important;
        -webkit-background-color: #fff !important;
    }

    .tubiao {
        width: 30px;
        height: 25px;
        position: absolute;
        /* left: 12%; */
        padding-top: 0px;
        opacity: 0.5;
    }

    .tubiao img {
        max-width: 100%;
        max-height: 100%;
    }

    .tubiao:hover {
        opacity: 1;
    }
</style>
<body>
<div class="content">
    <div>
        <a class="logo" href="/">
            <img src="images/logo2.png">
        </a>
    </div>
    <div class="formCon">
        <div id="login">
            <div class="formTitle">欢迎登录晟友</div>
            <form target="hidden_frame" class="login-form" onsubmit="return false;">
                <div class="group">
                    <input type="text" class="input user-email" name="username" id="username"
                           placeholder="请输入登录账号"
                           autocomplete="on"/>
                    <div class="error">
                        <span style="float:left;" class="login-user-error"></span>
                    </div>
                </div>
                <div class="group" style="position: relative;">
                    <input type="password" class="input user-password" name="password" id="password"
                           placeholder="请输入密码"/>
                    <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                    <div class="error">
                        <span style="float:left;" class="login-password"></span>
                    </div>
                </div>
                <div class="error">
<span style="float:left;display:none;" class="shake"
      id="not-ie">该应用不支持IE8及以下版本IE，请升级浏览器或换其他主流浏览器</span>
                </div>
                <button class="btn" id="login-btn2" type="button" onclick="loginindex()">
                    登录
                </button>
                <div class="forget">
                    <a href="javascript:;" class="forget-psw">忘记密码</a>
                </div>
            </form>
            <iframe name='hidden_frame' id="hidden_frame" style="display:none"></iframe>
        </div>
        <div id="change-new-password" style="display:none;">
            <p class="PassWordtitle">修改密码</p>
            <input type="text" placeholder="请输入旧密码" style='display: none' autocomplete="off"/>
            <input type="password" placeholder="请输入旧密码" style='display: none' autocomplete="off"/>
            <input type="password" placeholder="请输入旧密码" style='display: none' autocomplete="off"/>
            <div class="group" style="position: relative">
                <input type="password" class="input oldPassword" placeholder="请输入旧密码"/>
                <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                <div class="error">
                    <span style="float:left;" class="oldPassword-error"></span>
                </div>
            </div>
            <div class="group" style="position: relative">
                <input type="password" class="input newPassword1" placeholder="请输入新密码"/>
                <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                <div class="error">
                    <span style="float:left;" class="newPassword1-error"></span>
                </div>
            </div>
            <div class="group" style='margin-bottom: 0;position: relative'>
                <input type="password" class="input newPassword2" placeholder="再次输入新密码"/>
                <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                <div class="error">
                    <span style="float:left;" class="newPassword2-error"></span>
                </div>
            </div>
            <div style='font-size:13px;color:#999;text-align: center;line-height: 18px;margin-bottom: 15px'>
                <p style='margin: 0'>密码长度8至16位，且必须含有符号、大写字母、</p>
                <p style='margin: 0'>小写字母、数字四项中三项及以上 。</p>
            </div>
            <button class="btn" id="change-btn" type="submit">
                确定
            </button>
            <div><a href="javascript:;" style='margin-top:10px;display: block' class="back">返回登录</a></div>
        </div>
        <div id="forget-fist" style="display:none;">
            <div class="forgetTitle">忘记密码</div>
            <p class="title">验证(1/2)</p>
            <div class="group">
                <input type="text" class="input send-user" placeholder="请输入登录邮箱"/>
                <div class="error">
                    <span style="float:left;" class="first-email"></span>
                </div>
            </div>
            <div class="group">
                <div class="send-con">
                    <input type="password" maxlength="4" class="input first-code" placeholder="请输入验证码"/>
                    <a href="javascript:;" class="send-code">发送验证码</a>
                </div>
                <div class="error">
                    <span style="float:left;" class="first-code-tip"></span>
                </div>
            </div>
            <button class="btn goNext">
                下一步
            </button>
            <div><a href="javascript:;" class="back">去登录</a></div>
        </div>
        <div id="forget-second" style="display:none;">
            <div class="forgetTitle">忘记密码</div>
            <p class="title">验证(2/2)</p>
            <div class="group">
                <input type="password" class="input change-password-first " placeholder="请输入密码"/>
                <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                <div class="error">
                    <span style="float:left;" class="password-first-tip"></span>
                </div>
            </div>
            <div class="group" style="position: relative">
                <input type="password" class="input change-password-second" placeholder="请再次输入密码"/>
                <a class="tubiao dj" title="点击隐藏或显示密码"><img src="/static/images/eye-off.png"/></a>
                <div class="error">
                    <span style="float:left;" class="password-second-tip"></span>
                </div>
            </div>
            <div style='font-size:13px;color:#999;text-align: center;line-height: 18px;margin-bottom: 15px'>
                <p style='margin: 0'>密码长度8至16位，且必须含有符号、大写字母、</p>
                <p style='margin: 0'>小写字母、数字四项中三项及以上 。</p>
            </div>
            <button class="btn complete-change" style="margin-bottom:10px;">
                确认修改
            </button>
            <div><a href="javascript:;" class="back">去登录</a></div>
        </div>
    </div>
</div>
<div class="contentLoading">加载中...</div>
</body>
<script src="https://public.feeclouds.com/homepage/js/jquery.min.js"></script>
<script src="https://app-fc-public-prod.oss-cn-beijing.aliyuncs.com/homepage/js/crypto-js.js"></script>
<script type="text/javascript">
    window.onload = function () {
        let host = "", url = location.hostname, href = window.location.href, origin = "";
        if (url === '127.0.0.1') {
            host = "http://8.141.174.255:8084"
        }
        const themeConfig = JSON.parse(localStorage.getItem("themeConfig") || "{}")
        let theLoginConf = {
            ico: "",
            logo: "",
            title: "",
            banner: "",
            welcome: "",
            loginButtonColor: ""
        }
        if (themeConfig.id !== "") {
//有存储
            if (themeConfig.expires !== "" && themeConfig.expires + "000" >= new Date().valueOf()) {
//存储图片没过期
                const {
                    companyName, loginLogo, ico,
                    loginBanner,
                    loginButtonColor,
                    loginText,
                } = themeConfig;
                theLoginConf.ico = ico;
                theLoginConf.logo = loginLogo ? `url("${loginLogo}")` : "none";
                theLoginConf.title = companyName;
                theLoginConf.banner = loginBanner ? `url("${loginBanner}")` : "none";
                theLoginConf.welcome = loginText;
                theLoginConf.loginButtonColor = loginButtonColor;
                callback(theLoginConf)
            } else {
                queryImgs(callback)
            }
        } else {
//没有存储
            queryImgs(callback)
        }

        function notResultHandle() {
            switch (true) {
                case href.includes('fapiao.crmatmobile'): {
                    theLoginConf.ico = ""
                    theLoginConf.logo = ""
                    theLoginConf.title = "软素发票"
                    theLoginConf.welcome = "欢迎登录费耘"
                    theLoginConf.banner = `url("https://app-op-public-prod.oss-cn-beijing.aliyuncs.com/p_fcbanner/p_fc_banner.jpg")`;
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                case href.includes('invoice.gfcchina'): {
                    theLoginConf.ico = origin + '/static/images/gfc.ico'
                    theLoginConf.logo = `url("${origin}/static/images/jzlogo.png")`
                    theLoginConf.title = "嘉中咨询"
                    theLoginConf.banner = `url("${origin}/static/images/jzbj.png")`
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                case href.includes('fapiao.keycess.com'): {
                    theLoginConf.ico = origin + '/static/images/bitbug_favicon.ico'
                    theLoginConf.title = "启成咨询"
                    theLoginConf.banner = `url("${origin}/static/images/keycess.png")`
                    theLoginConf.loginButtonColor = "#99cb38"
                }
                    ;
                    break;
                case href.includes('bayerinvoice'): {
                    theLoginConf.ico = origin + '/static/images/br.ico'
                    theLoginConf.logo = `url("${origin}/static/images/brloginlogo.jpg")`
                    theLoginConf.title = "拜耳"
                    theLoginConf.banner = `url("${origin}/static/images/brbj2.png")`
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                case href.includes('dfyr.feeclouds.com'): {
                    theLoginConf.ico = origin + '/static/images/dfyr_ico.ico'
                    theLoginConf.logo = `url("${origin}/static/images/dfyr_login.png")`
                    theLoginConf.title = "东方银软"
                    theLoginConf.banner = `url("${origin}/static/images/p_dfyr_banner.png")`
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                case href.includes('caiyun618.com'): {
                    theLoginConf.ico = origin + '/static/images/caiyun618.ico'
                    theLoginConf.logo = `url("${origin}/static/images/caiyun618_logo.jpg")`
                    theLoginConf.title = "彩韵信息科技"
                    theLoginConf.banner = `url("${origin}/static/images/caiyun618_login.png")`
                    theLoginConf.welcome = "Welcom To CAIYUN"
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                case href.includes('bjbwjf.feeclouds.com'): {
                    theLoginConf.ico = origin + '/static/images/bjbwjf_ico.ico'
                    theLoginConf.logo = `url("${origin}/static/images/bjbwjf_lgoin.png")`
                    theLoginConf.title = "百旺金福"
                    theLoginConf.banner = `url("${origin}/static/images/bjbwjf_banner.jpeg")`
                    theLoginConf.welcome = "欢迎登录百旺金福"
                    theLoginConf.loginButtonColor = "rgb(24, 144, 255)"
                }
                    ;
                    break;
                default: {
                    theLoginConf = {
                        ico: origin + "/static/images/feiyun.ico",
                        logo: `url("${origin}/static/images/login_logo.svg")`,
                        title: "费耘",
                        banner: `url("https://app-op-public-prod.oss-cn-beijing.aliyuncs.com/p_fcbanner/p_fc_banner.jpg")`,
                        welcome: "欢迎登录费耘",
                        loginButtonColor: "rgb(24, 144, 255)"
                    }
                }
            }
            callback(theLoginConf)
        }

        function queryImgs(callback) {
//图片链接过期了
            $.get(host + "/bingo/getOem", {
                url,
            }, (res) => {
                if (res.message) {
                    notResultHandle()
                }
                if (res.data.id != "") {
// 有结果
                    localStorage.setItem("themeConfig", JSON.stringify(res.data))
                    const {
                        companyName, loginLogo, ico,
                        loginBanner,
                        loginButtonColor,
                        loginText,
                    } = res.data;
                    theLoginConf.ico = ico;
                    theLoginConf.logo = loginLogo ? `url("${loginLogo}")` : "none";
                    theLoginConf.title = companyName;
                    theLoginConf.banner = loginBanner ? `url("${loginBanner}")` : "none";
                    theLoginConf.welcome = loginText;
                    theLoginConf.loginButtonColor = loginButtonColor;
                    callback(theLoginConf)
                } else {
//没结果
                    notResultHandle()
                }
            }).fail(function (err) {
                notResultHandle()
            })
        }

        function callback(theLoginConf) {
            document.title = theLoginConf.title;
            document.querySelector(".formCon").style.backgroundImage = theLoginConf.banner
            document.querySelector(".formTitle").innerText = theLoginConf.welcome
            document.querySelector("#ico").setAttribute("href", theLoginConf.ico)
            document.querySelector(".logo").style.backgroundImage = theLoginConf.logo
            $('.btn').css('background', theLoginConf.loginButtonColor)
        }

//登录
        var apiUrl = '';
// var apiUrl = 'http://192.168.1.244:8000' // 联调阶段
        $(".dj").click(function () {
            if ($(this).prev().attr('type') == 'text') {
                $(this).prev().attr("type", "password");
                $(this).find('img').css("opacity", 0.5)
                $(this).find('img').attr("src", "/static/images/eye-off.png")
            } else {
                $(this).prev().attr("type", "text");
                $(this).find('img').css("opacity", 1)
                var img = $(this).find('img').attr("src");
                if (img == "/static/images/eye-open.png") {
                    $(this).find('img').attr("src", "/static/images/eye-off.png")
                } else {
                    $(this).find('img').attr("src", "/static/images/eye-open.png")
                }
            }
        });
        var convertURL = function (url) {
            if (url) {
                var timeStamp = (new Date()).valueOf();
                var tempArray = url.split("?");
                var tempArrayLength = tempArray.length;
                if (tempArrayLength == 2) {
                    url = url + "&timeStamp=" + timeStamp;
                } else if (tempArrayLength == 1) {
                    url = url + "?timeStamp=" + timeStamp;
                }
                return url;
            }
        }
        var getDES = function Encrypt(word) {
            var key = CryptoJS.enc.Utf8.parse("qwertyuiopasdfgh");
            var srcs = CryptoJS.enc.Utf8.parse(word);
            var encrypted = CryptoJS.AES.encrypt(srcs, key, {
                mode: CryptoJS.mode.ECB,
                padding: CryptoJS.pad.Pkcs7
            });
            return encrypted.toString();
        }
        $("#login-btn").on('click', function () {
            loginFnc();
        });
        $("#change-btn").on('click', function () {
            changeFnc();
        });
        $(document).on("keydown", function (e) {
            e = e || event;
            var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (keyCode == 13) {
                $("#login-btn").unbind("click")
                loginFnc();
            }
        });
        var changeFnc = function () { // 修改密码
            var old_password = $(".oldPassword").val();
            var new_password1 = $(".newPassword1").val();
            var new_password2 = $(".newPassword2").val();
            var username = $(".user-email").val();
            if (!old_password) {
                $(".oldPassword-error").text("请输入密码").show().addClass("shake");
                return;
            } else {
                $(".oldPassword-error").text("").hide().removeClass("shake");
            }
            if (!new_password1) {
                $(".newPassword1-error").text("请输入新密码").show().addClass("shake");
                return;
            } else {
                $(".newPassword1-error").text("").hide().removeClass("shake");
            }
            if (!new_password2) {
                $(".newPassword2-error").text("请再次输入新密码").show().addClass("shake");
                return;
            } else {
                $(".newPassword2-error").text("").hide().removeClass("shake");
            }
            if (new_password1 !== new_password2) {
                $(".newPassword2-error").text("两次输入的密码不一致").show().addClass("shake");
                return;
            } else {
                $(".newPassword2-error").text("").hide().removeClass("shake");
            }
            if (new_password2) {
                if (!(/((^(?=.*[a-z])(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[a-z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[\da-zA-Z\W]{8,16}$))/.test(new_password2))) {
                    $(".newPassword2-error").text("密码长度8至16位，且必须含有符号、大写字母、小写字母、数字四项中三项及以上").show().addClass("shake");
                    return;
                } else {
                    $(".newPassword2-error").text("").hide().removeClass("shake");
                }
            }
            $.ajax({
                type: 'POST',
                url: convertURL(apiUrl + '/ajax/user/first/reset/pwd'),
                withCredentials: true,
                dataType: 'json',
                data: {
                    username: username,
                    old_password: getDES(old_password),
                    new_password: getDES(new_password2)
                },
                success: function (res) {
                    if (res.code == 0) {
                        alert('密码修改成功')
                        $("#change-new-password").hide();
                        $(".newPassword1-error").text("").hide().removeClass("shake");
                        $(".newPassword2-error").text("").hide().removeClass("shake");
                        $("#login").show().addClass("fadeIn");
                        $("#login-btn").on('click', function () {
                            loginFnc();
                        });
                    } else {
                        $(".newPassword2-error").text(res.msg).show().addClass("shake");
                        return;
                        $(".newPassword1-error").text(res.msg).show().addClass("shake");
                        return;
                    }
                },
                error: function (res) {
                    $(".newPassword2-error").text(res.msg).show().addClass("shake");
                    $(".newPassword1-error").text(res.msg).show().addClass("shake");
                    $("#change-btn").on('click', function () {
                        changeFnc();
                    });
                }
            })
        }
        console.log(window.location)
// 获取地址栏中的查询参数
        const params = new URLSearchParams(window.location.search);
// 示例：获取名为 "id" 的参数值
        const token = params.get('token');
        const path = params.get('path');
        console.log(path)
        if (!token) {
            $('.content').show();
        }
        if (token) {
            $('.contentLoading').show();
// loginFnc()
// $.ajax({
// type: 'POST',
// dataType: 'json',
// url: convertURL(apiUrl + '/ajax/user/login'),
// data: {
// username: 'yutu@qq.com',
// password: getDES('1')
// },
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: convertURL(apiUrl + '/nologin/user/login'),
                data: {
                    token: token
                },
                success: function (res) {
                    console.log('23333333333')
                    if (res.code == 0) {
                        window.location.assign(path ? path : '/owns/ETCbinding');
                    } else {
                        console.log(res)
                    }
                },
                error: function (res) {
                    console.log(res)
                }
            })
        }
        var loginFnc = function () {
            $("#login-btn").unbind("click")
            var user = $(".user-email").val();
            var psw = $(".user-password").val();
            if (!user) {
                $(".login-user-error").text("请输入账号").show().addClass("shake");
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            } else if (window.location.href.indexOf('https://www.feeclouds.com') > -1 && !/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(user)) {
                $(".login-user-error").text("邮箱格式不正确").show().addClass("shake");
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            } else {
                $(".login-user-error").text("").hide().removeClass("shake");
            }
            if (!psw) {
                $(".login-password").text("请输入密码").show().addClass("shake");
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            } else {
                $(".login-password").text("").hide().removeClass("shake");
            }
            if (navigator.appName === "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i) === "7.") {
                $("#not-ie").show();
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            }
            if (navigator.appName === "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) === "8.") {
                $("#not-ie").show();
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            }
            if (navigator.appName === "Microsoft Internet Explorer" && navigator.appVersion.match(/6./i) === "6.") {
                $("#not-ie").show();
                $("#login-btn").on('click', function () {
                    loginFnc();
                });
                return;
            }
            // $.ajax({
            //     type: 'POST',
            //     dataType: 'json',
            //     url: convertURL(apiUrl + '/ajax/user/login'),
            //     data: {
            //         username: user,
            //         password: getDES(psw)
            //     },
            //     success: function (res) {
            //         if (res.code == 0) {
            //             if (res.data && res.data.last_login != '') {
            //                 $(".login-user-error").text("").hide().removeClass("shake");
            //                 $(".login-password").text("").hide().removeClass("shake");
            //                 window.location.assign("/home");
            //             } else {
            //                 $(".login-user-error").text("").hide().removeClass("shake");
            //                 $(".login-password").text("").hide().removeClass("shake");
            //                 $("#login").hide();
            //                 $("#change-new-password").show().addClass("fadeIn"); // 修改新密码
            //             }
            //         } else if (res.code == 10103) { // 密码输入错误
            //             if (res.data && res.data.remaining_times) {
            //                 $(".login-password").text("密码错误，还剩余" + res.data.remaining_times + '次输入机会').show().addClass("shake");
            //             } else {
            //                 $(".login-password").text("密码错误").show().addClass("shake");
            //             }
            //             $("#login-btn").on('click', function () {
            //                 loginFnc();
            //             });
            //         } else if (res.code == 10209) { // 错误超过5次后对该账号进行限制登录，限制时间为20分钟；
            //             $(".login-password").text(res.msg).show().addClass("shake");
            //             $("#login-btn").on('click', function () {
            //                 loginFnc();
            //             });
            //         } else {
            //             $(".login-password").text(res.msg).show().addClass("shake");
            //             $("#login-btn").on('click', function () {
            //                 loginFnc();
            //             });
            //         }
            //     },
            //     error: function (res) {
            //         $(".login-password").text(res.msg).show().addClass("shake");
            //         $("#login-btn").on('click', function () {
            //             loginFnc();
            //         });
            //     }
            // })
        };
//忘记密码
        $(".forget-psw").on("click", function () {
            $("#login").hide();
            $("#forget-fist").show().addClass("fadeIn");
        });
//发送验证码
        var canSend = true;
        var time = 120;
        $(".send-code").on("click", function () {
            var user = $(".send-user").val();
            if (!user) {
                $(".first-email").text("请输入邮箱").show().addClass("shake");
                return;
            } else if (window.location.href.indexOf('https://www.feeclouds.com') > -1 && user.indexOf("@") == -1) {
                $(".first-email").text("邮箱格式不正确").show().addClass("shake");
                return;
            } else {
                $(".first-email").text("").hide().removeClass("shake");
            }
            if (canSend) {
                canSend = false;
                $(".send-code").text('重发 (' + time + ')');
                var timer = setInterval(
                    function () {
                        time--;
                        $(".send-code").text('重发 (' + time + ')');
                        if (time == 0) {
                            clearInterval(timer);
                            timer = null;
                            time = 120;
                            canSend = true;
                            $(".send-code").text('发送验证码');
                        }
                    },
                    1000
                );
                $.ajax({
                    type: 'POST',
                    dataType: 'json',
                    url: convertURL(apiUrl + '/ajax/user/code/send'),
                    data: {
                        username: user
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            $(".first-email").text("").hide().removeClass("shake");
                        } else {
                            $(".first-email").text(res.msg).show().addClass("shake");
                            clearInterval(timer);
                            timer = null;
                            time = 120;
                            canSend = true;
                            $(".send-code").text('发送验证码');
                        }
                    }
                })
            }
        });
//下一步
        var userName = '';
        var userCode = '';
        $(".goNext").on("click", function () {
            var firstEmail = $(".send-user").val();
            var firstCode = $(".first-code").val();
            if (!firstEmail) {
                $(".first-email").text("请输入邮箱").show().addClass("shake");
                return;
            }
            if (!/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(firstEmail)) {
                $(".first-email").text("邮箱格式不正确").show().addClass("shake");
                return;
            }
            $(".first-email").text("").hide().removeClass("shake");
            if (!firstCode) {
                $(".first-code-tip").text("请输入验证码").show().addClass("shake");
                return;
            }
            if (!/^\d{4}$/.test(firstCode)) {
                $(".first-code-tip").text("请输入正确的验证码").show().addClass("shake");
                return;
            }
            $(".first-code-tip").text("").hide().removeClass("shake");
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: convertURL(apiUrl + '/ajax/user/code/verify'),
                data: {
                    username: firstEmail,
                    code: firstCode
                },
                success: function (res) {
                    if (res.code == 0) {
                        userName = firstEmail;
                        userCode = firstCode;
                        $(".first-code-tip").text("").hide().removeClass("shake");
                        $("#forget-fist").hide();
                        $("#forget-second").show().addClass("fadeIn");
                    } else {
                        $(".first-code-tip").text(res.msg).show().addClass("shake");
                    }
                }
            })
        });
//完成修改
        $(".complete-change").on("click", function () {
            var firstPassword = $(".change-password-first").val();
            var secondPassword = $(".change-password-second").val();
            if (!firstPassword) {
                $(".password-first-tip").text("请输入密码").show().addClass("shake");
                return;
            } else {
                $(".password-first-tip").text("").hide().removeClass("shake");
            }
            if (!secondPassword) {
                $(".password-second-tip").text("请再次输入密码").show().addClass("shake");
                return;
            } else {
                $(".password-second-tip").text("").hide().removeClass("shake");
            }
            if (firstPassword != secondPassword) {
                $(".password-second-tip").text("两次输入的密码不一致").show().addClass("shake");
                return;
            } else {
                $(".password-second-tip").text("").hide().removeClass("shake");
            }
            if (secondPassword) {
                if (!(/((^(?=.*[a-z])(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[A-Z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[a-z])(?=.*\W)[\da-zA-Z\W]{8,16}$)|(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[\da-zA-Z\W]{8,16}$))/.test(secondPassword))) {
                    $(".password-second-tip").text("密码长度8至16位，且必须含有符号、大写字母、小写字母、数字四项中三项及以上").show().addClass("shake");
                    return;
                } else {
                    $(".password-second-tip").text("").hide().removeClass("shake");
                }
            }
            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: convertURL(apiUrl + '/ajax/user/code/reset'),
                data: {
                    username: userName,
                    code: userCode,
                    new_password: getDES(secondPassword)
                },
                success: function (res) {
                    if (res.code == 0) {
                        $(".password-second-tip").text("").hide().removeClass("shake");
                        $("#forget-second").hide();
                        $("#login").show().addClass("fadeIn");
                    } else {
                        $(".password-second-tip").text(res.msg).show().addClass("shake");
                    }
                }
            })
        });
//返回登录
        $(".back").on("click", function () {
            $(".oldPassword").val('');
            $(".newPassword1").val('')
            $(".newPassword2").val('')
            $("#forget-fist,#forget-second").hide();
            $("#change-new-password").hide();
            $(".newPassword1-error").text("").hide().removeClass("shake");
            $(".newPassword2-error").text("").hide().removeClass("shake");
            $("#login").show().addClass("fadeIn");
            $("#login-btn").on('click', function () {
                loginFnc();
            });
        })
    }

    function loginindex(){
        window.location.href="/";
    }
</script>
</html>
